package com.laicunba.service.impl.helper;

import com.laicunba.util.RedisUtil;

public class JsScriptRedisHelper {
	private final static String PREFIX = "JS_REDIS_";
	private final static int MAXDAY = 3600 * 24 * 20;

	public String getAttribute(String name) {
		return RedisUtil.get(PREFIX + name);
	}

	public void setAttribute(String name, String value, int seconds) {
		RedisUtil.set(PREFIX + name, value, seconds > MAXDAY || seconds <= 0 ? MAXDAY : seconds);
	}

	public Long removeAttribute(String name) {
		return RedisUtil.del(PREFIX + name);
	}

	public long incr(String key, int seconds) {

		return RedisUtil.incr(PREFIX + key, seconds > MAXDAY || seconds <= 0 ? MAXDAY : seconds);
	}

	public long expire(String key, int seconds) {
		return RedisUtil.expire(PREFIX + key, seconds > MAXDAY || seconds <= 0 ? MAXDAY : seconds);
	}
}
